﻿using System;
using System.Net;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Runtime.Serialization;
using RStein.PosterousReader.WP.ViewModels.ViewObjects;
using System.Collections.ObjectModel;
using RStein.PosterousReader.Common.ViewModelsHelpers;

namespace RStein.PosterousReader.WP.ViewModels.SpecialTypes
{
  [KnownType("GetKnownTypes")]
  public class KnownTypesDictionary : Dictionary<string, object>
  {
    private static Type[] KNOWN_TYPES = 
                                        {                                          
                                          typeof(KnownTypesDictionary)
                                        };
    
    private static  IEnumerable<Type> _cachedKnownTypes;
    
    public KnownTypesDictionary()
        : base()
      {

      }

    
    public KnownTypesDictionary(IDictionary<String, Object> originalDictionary) : base(originalDictionary)
    {

    }

    static KnownTypesDictionary()
    {
      KnownTypeProvider = new DefaultKnownTypesProvider();
    }
    
    public static IKnownTypeProvider KnownTypeProvider
    {

      get;
      set;
    }

    public static IEnumerable<Type> GetKnownTypes()
    {
      if (_cachedKnownTypes == null)
      {
        _cachedKnownTypes = KNOWN_TYPES.Union(KnownTypeProvider.GetKnownTypes()).Distinct().ToList();
      }

      return _cachedKnownTypes;
    }
  }
  
  

}
